home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / haeberli / libgutil / percent.c < prev    next >
C/C++ Source or Header  |  1994-08-01  |  3KB  |  123 lines

  1. /*
  2.  * Copyright 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. /*
  18.  *    percent - 
  19.  *        Indicate percent done on time consuming operations.
  20.  *
  21.  *                Paul Haeberli - 1985
  22.  *
  23.  */
  24. #include "gl.h"
  25. #include "device.h"
  26.  
  27. #define NCURSORS    11
  28.  
  29. static unsigned short curtab[NCURSORS][16] = {
  30.     {0x7FFE, 0x4002, 0x2004, 0x300C, 
  31.     0x2894, 0x2424, 0x2244, 0x2244, 
  32.     0x2344, 0x23C4, 0x27E4, 0x2FF4, 
  33.     0x3FFC, 0x3FFC, 0x4FF2, 0x7FFE},
  34.  
  35.     {0x7FFE, 0x43C2, 0x2184, 0x300C, 
  36.     0x2814, 0x2424, 0x2244, 0x2244, 
  37.     0x22C4, 0x23C4, 0x27E4, 0x2FF4, 
  38.     0x3FFC, 0x2FF4, 0x47E2, 0x7FFE},
  39.  
  40.     {0x7FFE, 0x47E2, 0x23C4, 0x308C, 
  41.     0x2814, 0x2424, 0x2244, 0x2244, 
  42.     0x22C4, 0x23C4, 0x27E4, 0x2FF4, 
  43.     0x3FFC, 0x27F4, 0x4182, 0x7FFE},
  44.  
  45.     {0x7FFE, 0x4FE2, 0x27C4, 0x318C, 
  46.     0x2914, 0x2424, 0x2244, 0x2244, 
  47.     0x22C4, 0x23C4, 0x27E4, 0x2FF4, 
  48.     0x37FC, 0x23F4, 0x4082, 0x7FFE},
  49.  
  50.     {0x7FFE, 0x4FF2, 0x27E4, 0x33CC, 
  51.     0x2914, 0x2424, 0x2244, 0x2244, 
  52.     0x2344, 0x23C4, 0x27E4, 0x2FF4, 
  53.     0x37FC, 0x21C4, 0x4002, 0x7FFE},
  54.  
  55.     {0x7FFE, 0x4FFA, 0x27F4, 0x33EC, 
  56.     0x2994, 0x2424, 0x2244, 0x2244, 
  57.     0x22C4, 0x23C4, 0x27E4, 0x2FF4, 
  58.     0x37CC, 0x2084, 0x4002, 0x7FFE},
  59.  
  60.     {0x7FFE, 0x5FFA, 0x2FF4, 0x37EC, 
  61.     0x2B94, 0x2424, 0x2244, 0x2244, 
  62.     0x2344, 0x23C4, 0x27E4, 0x2FF4, 
  63.     0x318C, 0x2004, 0x4002, 0x7FFE},
  64.  
  65.     {0x7FFE, 0x7FFE, 0x3FF4, 0x37EC, 
  66.     0x2BD4, 0x2424, 0x2244, 0x2244, 
  67.     0x22C4, 0x23C4, 0x27E4, 0x2BD4, 
  68.     0x300C, 0x2004, 0x4002, 0x7FFE},
  69.  
  70.     {0x7FFE, 0x7FFE, 0x3FFC, 0x3FFC, 
  71.     0x2FD4, 0x2424, 0x2244, 0x2244, 
  72.     0x2344, 0x23C4, 0x27E4, 0x2814, 
  73.     0x300C, 0x2004, 0x4002, 0x7FFE},
  74.  
  75.     {0x7FFE, 0x7FFE, 0x3FFC, 0x3FFC, 
  76.     0x2FF4, 0x26E4, 0x2244, 0x2244, 
  77.     0x22C4, 0x23C4, 0x2424, 0x2814, 
  78.     0x300C, 0x2004, 0x4002, 0x7FFE},
  79.  
  80.     {0x7FFE, 0x7FFE, 0x3FFC, 0x3FFC, 
  81.     0x2FF4, 0x27E4, 0x23C4, 0x23C4, 
  82.     0x2244, 0x2244, 0x2424, 0x2814, 
  83.     0x300C, 0x2004, 0x4002, 0x7FFE},
  84. };
  85.  
  86. static int curindex = -1;
  87. static short oldcursor = 0;
  88.  
  89. percentdone(percent)
  90. float percent;
  91. {
  92.     int index; 
  93.     unsigned short dummy;
  94.     long ldummy;
  95.  
  96.     if((curindex == -1) && (percent == 0.0)) 
  97.     getcursor(&oldcursor,&dummy,&dummy,&ldummy);
  98.     if (percent > 99.9) {
  99.     setcursor(oldcursor,0xfff,0xfff);
  100.     curindex = -1;
  101.     } else {
  102.     index = percent*NCURSORS/100.0;
  103.     if (index<0)
  104.         index = 0;
  105.     if (index>=NCURSORS)
  106.         index = NCURSORS-1;
  107.     if (index != curindex) {
  108.         defcursor(20,curtab[index]);
  109.         curorigin(20,7,7);
  110.         setcursor(20,0xfff,0xfff);
  111.         curindex = index;
  112.     }
  113.     }
  114. }
  115.  
  116. dosystem(name)
  117. char *name;
  118. {
  119.     percentdone(50.0);
  120.     system(name);
  121.     percentdone(100.0);
  122. }
  123.